package com.shijiu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Author xlj
 * @Date Created in  2023/4/10 9:30
 * @DESCRIPTION:
 * @Version V1.0
 */

@Configuration
@EnableWebMvc
@EnableOpenApi
public class SwaggerConfig {
   @Bean
   public Docket createRestApi() {
      return new Docket(DocumentationType.SWAGGER_2)
              .apiInfo(apiInfo())
              .select()
              .apis(RequestHandlerSelectors.basePackage("com.shijiu.controller.controller"))
              .paths(PathSelectors.any())
              .build();
   }

   private ApiInfo apiInfo() {
      return new ApiInfoBuilder()
              .title("程序猿xiaoxia API")
              .description("xiaoxia springboot-swagger2 在线借口文档")
              .termsOfServiceUrl("https://blog.csdn.net/XikYu")
              .version("1.0")
              .build();
   }

}